﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using Tilver.DBConnectionUI;

namespace Tilver.DBConnectionUI.Postgre
{
    internal class PostgreStringBuilder: UDLStringBuilder
    {
        public PostgreStringBuilder()
        {
            Server = "localhost";
            Port = 5432;
            Database = "postgres";
            Protocol = "automatic";
            Pooling = true;
            MinPoolSize = 1;
            MaxPoolSize = 20;
            Timeout = 15;
            CommandTimeout = 20;
            SSL = false;
            Sslmode = "Disable";
            ConnectionLifetime = 15;
            SyncNotification = false;
            PreloadReader = false;

            RegisterAlias("Data Source", "Server");
            RegisterAlias("Location", "Database");
        }

        [Category("Connection")]
        public string Server { get; set; }

        [Category("Connection"),DefaultValue(5432)]
        public int Port { get; set; }

        [DefaultValue("automatic"), Category("Advanced")]
        public string Protocol { get; set; } //automatic,2,3

        [Category("Connection")]
        public string Database { get; set; }

        [DisplayName("User ID"),Category("Security"),PasswordPropertyText(true)]
        public string UserID { get; set; }

        [Category("Security"), PasswordPropertyText()]
        public string Password { get; set; }

        [DisplayName("Integrated Security"), Category("Security"),DefaultValue(false)]
        public bool IntegratedSecurity { get; set; }

        [Category("Security"), DefaultValue(false)]
        public bool SSL { get; set; }

        [DefaultValue(true), Category("Advanced")]
        public bool Pooling { get; set; }

        [DefaultValue(1), Category("Advanced")]
        public int MinPoolSize { get; set; }

        [DefaultValue(20), Category("Advanced")]
        public int MaxPoolSize { get; set; }

        [DefaultValue(15), Category("Advanced")]
        public int Timeout { get; set; }

        [DefaultValue(20), Category("Advanced")]
        public int CommandTimeout { get; set; }

        [DefaultValue("Disable"), Category("Advanced")]
        public string Sslmode { get; set; } //Prefer,Require,Allow,Disable

        [DefaultValue(15), Category("Advanced")]
        public int ConnectionLifetime { get; set; }

        [Category("Advanced"),DefaultValue(false)]
        public bool SyncNotification { get; set; }

        [Category("Advanced")]
        public string SearchPath { get; set; }

        [DisplayName("Preload Reader"), Category("Advanced"),DefaultValue(false)]
        public bool PreloadReader { get; set; }

        [Category("Advanced")]
        public string Compatibility { get; set; }

    }
}
